package org.thread.test02.homework2;/*
 *@Author: gjh
 *Date: 2025/3/715:02
 *Describe:
 */

public class Test {
    /*编写一个Java程序，
    创建一个守护线程和一个用户线程，
    用户线程实现文件的拷贝，
    而守护线程实现打印输出拷贝进度（每隔500毫秒输出一下进度*/

    public long count;
    public long doneByte;
    public final static Test test = new Test();
    public static boolean flag;

    public synchronized double getDoneByte(){
        if(this.count>0){
            return (double)this.doneByte / this.count * 100;
        }else{
            return 0;
        }
    }

    public static void main(String[] args) {
        CopyThread copyThread = new CopyThread();
        GuardThread guardThread = new GuardThread();
        guardThread.setDaemon(true);
        copyThread.start();
        guardThread.start();
    }
}
